package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

public class Set {
    public static void main(String[] args) {
        List<Dog> list = new ArrayList<>();
        Dog d1 = new Dog("旺财", 2);
        Dog d2 = new Dog("小黑", 3);
        Dog d3 = new Dog("小白", 2);
        Dog d4 = new Dog("哮天犬", 99);
        Dog d5 = new Dog("旺财", 2);
        Collections.addAll(list,d1,d2,d3,d4,d5);
        System.out.println(list);
        HashSet<Dog> set = new HashSet<>();
        set.addAll(list);
        System.out.println(set);//重写Dog类的hashCode和equals方法,set可以去除Dog实例对象属性重复的

    }
}
